package gobase

import "math/rand"

var (
	// 使用下面的r, 并发会有异常
	// r *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))

	hex_strs    = "0123456789ABCDEF"
	key_strs    = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	pass_0_strs = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
	num_strs    = "0123456789"
	num2_strs   = "012356789"
)

// 60个纤程同时进行测试没有异常
func RandHexString(len int) string {
	bytes := make([]byte, len)
	for i := 0; i < len; i++ {
		b := rand.Intn(16)
		bytes[i] = byte(hex_strs[b])
	}
	return string(bytes)
}

func RandFloat64(f float64) float64 {
	return f * float64(rand.Intn(100)) / 100.00
}
